GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 6df68c...3f1292 )
by Florian
01:13
created

NPA.getInfo   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 48

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 48
rs 9.125

2 Functions

Rating   Name   Duplication   Size   Complexity  
A 0 6 1
A 0 16 2
1
/*jslint
2
  indent: 4
3
*/
4
5
/*global
6
  $, google, showAlert, mytrans
7
*/
8
9
var NPA = {};
10
NPA.m_map = null;
11
NPA.m_layer = null;
12
NPA.m_layerShown = false;
13
NPA.m_infoMode = false;
14
NPA.m_clickListener = null;
15
16
17
NPA.init = function (map) {
18
    'use strict';
19
20
    this.m_map = map;
21
};
22
23
24 View Code Duplication
NPA.getLayer = function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
25
    'use strict';
26
27
    if (!this.m_layer) {
28
        var tileSize = 256,
29
            themap = this.m_map;
30
        this.m_layer = new google.maps.ImageMapType({
31
            getTileUrl: function (coord, zoom) {
32
                var proj = themap.getProjection(),
33
                    zfactor = tileSize / Math.pow(2, zoom),
34
                    top = proj.fromPointToLatLng(new google.maps.Point(coord.x * zfactor, coord.y * zfactor)),
35
                    bot = proj.fromPointToLatLng(new google.maps.Point((coord.x + 1) * zfactor, (coord.y + 1) * zfactor)),
36
                    bbox = top.lng() + "," + bot.lat() + "," + bot.lng() + "," + top.lat(),
37
                    url;
38
                url = "https://geodienste.bfn.de/ogc/wms/schutzgebiet?" +
39
                    "&REQUEST=GetMap" +
40
                    "&SERVICE=WMS" +
41
                    "&VERSION=1.3.0" +
42
                    "&LAYERS=Naturschutzgebiete" +
43
                    "&FORMAT=image/png" +
44
                    "&BGCOLOR=0xFFFFFF" +
45
                    "&STYLES=default" +
46
                    "&TRANSPARENT=TRUE" +
47
                    "&CRS=CRS:84" +
48
                    "&BBOX=" + bbox +
49
                    "&WIDTH=" + tileSize +
50
                    "&HEIGHT=" + tileSize;
51
                return url;
52
            },
53
            tileSize: new google.maps.Size(tileSize, tileSize),
54
            isPng: true,
55
            opacity: 0.6
56
        });
57
    }
58
    return this.m_layer;
59
};
60
61
62
NPA.getPopupContentFromResponse = function (json) {
63
    'use strict';
64
65
    if (json && json.features && json.features.length > 0) {
66
        return '<b>' + json.features[0].properties.NAME + '</b><br/>' +
67
            mytrans("dialog.npa.cdda_code") + ' ' + json.features[0].properties.CDDA_CODE + '<br />' +
68
            mytrans("dialog.npa.since") + ' ' + json.features[0].properties.JAHR + '<br />' +
69
            mytrans("dialog.npa.area") + ' ' + json.features[0].properties.FLAECHE + ' ha<br />';
70
    }
71
72
    return null;
73
};
74
75
76
NPA.getInfo = function (coords) {
77
    'use strict';
78
79
    var self = this,
80
        url = 'https://geodienste.bfn.de/ogc/wms/schutzgebiet',
81
        data = {
82
            REQUEST: "GetFeatureInfo",
83
            SERVICE: "WMS",
84
            VERSION: "1.3.0",
85
            CRS: "CRS:84",
86
            BBOX: coords.lng() + ',' + coords.lat() + ',' + (coords.lng() + 0.001) + ',' + (coords.lat() + 0.001),
87
            WIDTH: 256,
88
            HEIGHT: 256,
89
            INFO_FORMAT: "application/geojson",
90
            FEATURE_COUNT: 1,
91
            QUERY_LAYERS: "Naturschutzgebiete",
92
            X: 0,
93
            Y: 0
94
        };
95
    $.ajax({
96
        url: "proxy2.php",
97
        dataType: "json",
98
        data: {
99
            url: url + "?" + $.param(data)
100
        },
101
        timeout: 3000
102
    }).done(function (data) {
103
        var content = self.getPopupContentFromResponse(data),
104
            infowindow;
105
        if (content) {
106
            infowindow = new google.maps.InfoWindow({
107
                content: content,
108
                position: coords
109
            });
110
            infowindow.open(self.m_map);
111
        } else {
112
            showAlert(
113
                mytrans("dialog.information"),
114
                mytrans("dialog.npa.msg_no_npa")
115
            );
116
        }
117
    }).fail(function () {
118
        showAlert(
119
            mytrans("dialog.error"),
120
            mytrans("dialog.npa.error")
121
        );
122
    });
123
};
124
125
126
NPA.toggle = function (t) {
127
    'use strict';
128
129
    if ($('#npa').is(':checked') !== t) {
130
        $('#npa').attr('checked', t);
131
    }
132
133
    if (t) {
134
        $('#npa_details').show();
135
    } else {
136
        $('#npa_details').hide();
137
        this.endInfoMode();
138
    }
139
140
    if (this.m_layerShown === t) {
141
        return;
142
    }
143
    this.m_layerShown = t;
144
145
    if (t) {
146
        this.m_map.overlayMapTypes.push(this.getLayer());
147
    } else if (this.m_layer) {
148
        this.m_map.overlayMapTypes.removeAt(this.m_map.overlayMapTypes.indexOf(this.m_layer));
149
    }
150
};
151
152
153
NPA.showDialog = function () {
154
    'use strict';
155
156
    $('#dialogNPA').modal({show: true, backdrop: "static", keyboard: true});
157
};
158
159
160
NPA.startInfoMode = function () {
161
    'use strict';
162
163
    if (this.m_infoMode) {
164
        return;
165
    }
166
167
    var self = this;
168
    this.m_map.setOptions({draggableCursor: 'help'});
169
    this.m_infoMode = true;
170
    this.m_clickListener = google.maps.event.addListener(this.m_map, 'click', function (event) {
171
        self.getInfo(event.latLng);
172
        self.endInfoMode();
173
    });
174
};
175
176
177
NPA.endInfoMode = function () {
178
    'use strict';
179
180
    if (!this.m_infoMode) {
181
        return;
182
    }
183
184
    this.m_map.setOptions({draggableCursor: ''});
185
    this.m_infoMode = false;
186
    google.maps.event.removeListener(this.m_clickListener);
187
};
188